<?php

class Thread_m extends MY_Model {

    protected $_table_name = 'tbl_threads';
    protected $_primary_key = 'thread_id';
    protected $_primary_filter = 'intval';
    protected $_order_by = '';

    /* public  $rules_topic=array(
      'topic_name'=> array(
      'field'=>'topic_title',
      'label'=>'Topic Title',
      'rules'=>'trim|required|callback__unique_topic||xss_clean'),

      'topic_content'=> array(
      'field'=>'topic_content',
      'label'=>'topic Content',
      'rules'=>'trim|required'),
      );

      public  function get_new_topic(){
      $topic= new stdClass();
      $topic->topic_title			='';
      $topic->topic_content		='';
      $topic->topic_dated			='';
      $topic->topic_author		='';
      $topic->topic_status		='';
      return $topic;
      }
      public function array_from_post($fields){
      $data=array();
      foreach ($fields as $field){
      $data[$field]=$this->input->post($field);
      }
      return $data;
      } */

    public function __construct() {
        parent::__construct();
    }

    // pagination 
    public function record_count($id) {
        $this->db->where('topic_id', $id);
        $this->db->from($this->_table_name);
        return $this->db->count_all();
    }

    public function fetch_topic($limit, $start) {
        $this->db->limit($limit, $start);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
    }

}